<template>
  <div class="not-found">
    <div class="content">
      <el-result
        icon="error"
        title="404"
        sub-title="抱歉，您访问的页面不存在"
      >
        <template #extra>
          <div class="action-buttons">
            <el-button type="primary" @click="goBack">
              <el-icon><Back /></el-icon>返回上一页
            </el-button>
            <el-button @click="goHome">
              <el-icon><House /></el-icon>返回首页
            </el-button>
          </div>
        </template>

        <template #icon>
          <div class="custom-icon">
            <div class="number">404</div>
            <div class="shadow"></div>
          </div>
        </template>
      </el-result>

      <!-- 可能的页面建议 -->
      <div class="suggestions" v-if="suggestions.length > 0">
        <h3>您可能想访问：</h3>
        <el-space direction="vertical" alignment="flex-start">
          <el-link 
            v-for="suggestion in suggestions" 
            :key="suggestion.path"
            :href="suggestion.path"
            type="primary"
          >
            <el-icon><Link /></el-icon>
            {{ suggestion.name }}
          </el-link>
        </el-space>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { Back, House, Link } from '@element-plus/icons-vue'

const router = useRouter()

// 页面建议
const suggestions = ref([
  { name: '运输计划', path: '/planning' },
  { name: '调度管理', path: '/dispatch' },
  { name: '报表中心', path: '/reports' },
  { name: '系统设置', path: '/settings' }
])

// 返回上一页
const goBack = () => {
  router.back()
}

// 返回首页
const goHome = () => {
  router.push('/')
}
</script>

<style scoped>
.not-found {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--el-bg-color);
}

.content {
  text-align: center;
  padding: 40px;
}

.custom-icon {
  position: relative;
  height: 160px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.number {
  font-size: 120px;
  font-weight: bold;
  background: linear-gradient(45deg, var(--el-color-primary), var(--el-color-danger));
  -webkit-background-clip: text;
  color: transparent;
  animation: float 4s ease-in-out infinite;
}

.shadow {
  position: absolute;
  bottom: 0;
  width: 160px;
  height: 20px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  animation: shadow 4s ease-in-out infinite;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.suggestions {
  margin-top: 40px;
  padding: 20px;
  background-color: var(--el-bg-color-page);
  border-radius: var(--el-border-radius-base);
  box-shadow: var(--el-box-shadow-light);
}

.suggestions h3 {
  color: var(--el-text-color-primary);
  margin-bottom: 16px;
}

:deep(.el-link) {
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes shadow {
  0%, 100% {
    transform: scale(1);
    opacity: 0.4;
  }
  50% {
    transform: scale(0.8);
    opacity: 0.2;
  }
}
</style>